﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlPhieu.ascx.cs"
    Inherits="WebUserControl_ControlPhieu" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="uscTitleForm.ascx" TagName="uscTitleForm" TagPrefix="uc1" %>
<%@ Register Src="uscMsgBox.ascx" TagName="uscMsgBox" TagPrefix="uc2" %>
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/datePicker.css")%>' type="text/css" />

<script type="text/javascript" src='<%=ResolveUrl("~/JScript/jquery.alphanumeric.js")%>'></script>

<script type="text/javascript">
    function pageLoad() {
        $("#<%= txtSoLuong.ClientID %>").numeric({ allow: "." });

        $(function() {
            $("#<%= txtNgay.ClientID %>").datePicker(
		{
		    clickInput: true,
		    startDate: '01/01/1970'
		}
	);
        });

        $("#<%= ImageButton3.ClientID %>").click(function() {
            $.blockUI({
                message: '<h1>Xin vui lòng chờ xử lý</h1>',
                css: {
                    border: 'none',
                    padding: '15px',
                    backgroundColor: '#f00',
                    opacity: .5,
                    color: '#fff'
                }
            });
        });
        $("#<%= ImageButton2.ClientID %>").click(function() {
            if ($("#<%= txtMaSoKhachHang.ClientID %>").val().length > 0 && $("#<%= txtTenKhachHang.ClientID %>").val().length > 0 && $("#<%= txtMaTuVanVien.ClientID %>").val().length > 0 && $("#<%= txtTuVanVien.ClientID %>").val().length > 0) {
                $.blockUI({
                    message: '<h1>Xin vui lòng chờ xử lý</h1>',
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#f00',
                        opacity: .5,
                        color: '#fff'
                    }
                });
            }
        });
        $("#<%= imgXoa.ClientID %>").click(function() {
            if ($("#<%= txtMaSoKhachHang.ClientID %>").val().length > 0 && $("#<%= txtTenKhachHang.ClientID %>").val().length > 0 && $("#<%= txtMaTuVanVien.ClientID %>").val().length > 0 && $("#<%= txtTuVanVien.ClientID %>").val().length > 0) {
                $.blockUI({
                    message: '<h1>Xin vui lòng chờ xử lý</h1>',
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#f00',
                        opacity: .5,
                        color: '#fff'
                    }
                });
            }
        });
        $("#<%= BtNhapToSession.ClientID %>").click(function() {
            if ($("#<%= txtMaSoKhachHang.ClientID %>").val().length > 0 && $("#<%= txtTenKhachHang.ClientID %>").val().length > 0 && $("#<%= txtMaTuVanVien.ClientID %>").val().length > 0 && $("#<%= txtTuVanVien.ClientID %>").val().length > 0) {
                $.blockUI({
                    message: '<h1>Xin vui lòng chờ xử lý</h1>',
                    css: {
                        border: 'none',
                        padding: '15px',
                        backgroundColor: '#f00',
                        opacity: .5,
                        color: '#fff'
                    }
                });
            }
        });

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {
            $.unblockUI();
        }
    }  
   
</script>

<style type="text/css">
    .AutoExtender
    {
        font-family: Verdana, Helvetica, sans-serif;
        font-size: .8em;
        font-weight: normal;
        border: solid 1px #006699;
        line-height: 20px;
        padding: 10px;
        background-color: White;
        margin-left: 10px;
    }
    .AutoExtenderList
    {
        border-bottom: dotted 1px #006699;
        cursor: pointer;
        color: Maroon;
    }
    .AutoExtenderHighlight
    {
        color: White;
        background-color: #006699;
        cursor: pointer;
    }
    #divwidth
    {
        width: auto !important;
    }
    #divwidth div
    {
        width: auto !important;
    }
</style>
<asp:ScriptManager ID="Scriptmanager1" runat="server">
</asp:ScriptManager>
<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>--%>
<uc1:usctitleform id="uscTitleForm1" runat="server" messeage="Tư vấn viên bán hàng cho khách hàng" />
<asp:Panel ID="Panel1" runat="server" BackColor="#EBEBEB" BorderStyle="None" Height="33px"
    Width="100%">
    &nbsp;<asp:ImageButton ID="ImageButton3" runat="server" Height="25px" ImageUrl="~/image/New File.png"
        Width="25px" CausesValidation="false" OnClick="ImageButton3_Click" />
    &nbsp;
    <asp:ImageButton ID="ImageButton2" runat="server" Height="25px" ImageUrl="~/image/Save.png"
        Width="25px" OnClick="ImageButton2_Click" />
    &nbsp;<asp:ImageButton ID="imgXoa" runat="server" Height="25px" ImageUrl="~/image/Symbol-Delete.png"
        Width="25px" OnClick="imgXoa_Click" />
    &nbsp;<asp:ImageButton ID="ImageButton4" Width="25px" CausesValidation="false" runat="server"
        Height="25px" ImageUrl="~/image/Find.png" OnClick="ImageButton4_Click" />
</asp:Panel>
<br />
<asp:Label ID="lblKetQua" runat="server" Font-Italic="True" ForeColor="#3333CC"></asp:Label>
<br />
<cc1:tabcontainer id="TabContainer1" runat="server" activetabindex="1" height="450px"
    width="906px">
    <cc1:TabPanel runat="server" HeaderText="Phiếu mua hàng" ID="TabPanel1">
        <HeaderTemplate>
            Phiếu mua hàng
        
        
    </HeaderTemplate>
        
<ContentTemplate>
            <div align="center">
                <table id="table1">
                    <tr>
                        <td>
                            <asp:Label Visible="False" ID="lblTitle" runat="server" Text="Số chứng từ"></asp:Label>

                        </td>
                        <td>
                            <asp:Label Visible="False" ID="lblSoChungTu" runat="server" Text="Label"></asp:Label>

                        </td>
                    </tr>
                    <tr>
                        <td width="21%">
                            Ngày
                        </td>
                        <td width="33%" colspan="3">
                            <asp:TextBox ID="txtNgay" runat="server" Width="150px"></asp:TextBox>

                        </td>
                        <td colspan="4">
                            <asp:CheckBox ID="CheckChot" Text="Chốt" runat="server" />

                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mã s&#7889; khách hàng
                        </td>
                        <td width="21%" colspan="2">
                            <asp:TextBox ID="txtMaSoKhachHang" OnTextChanged="txtMaSoKhachHang_TextChanged" runat="server"
                                AutoPostBack="True"></asp:TextBox>

                            <asp:RequiredFieldValidator ControlToValidate="txtMaSoKhachHang" Display="None" ID="R1"
                                runat="server" ErrorMessage="Phải nhập mã khách hàng"></asp:RequiredFieldValidator>

                            <cc1:ValidatorCalloutExtender TargetControlID="R1" ID="ValidatorCalloutExtender1"
                                runat="server" Enabled="True"></cc1:ValidatorCalloutExtender>

                        </td>
                        <td width="9%">
                            <asp:ImageButton ID="ImageTimKhachHang" Width="20px" runat="server" Height="20px"
                                ImageUrl="~/image/Search.png" CausesValidation="False" OnClick="ImageTimKhachHang_Click" />

                        </td>
                        <td width="15%">
                            Tên khách hàng
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txtTenKhachHang" runat="server" Width="200px"></asp:TextBox>

                            <asp:RequiredFieldValidator ControlToValidate="txtTenKhachHang" Display="None" ID="R2"
                                runat="server" ErrorMessage="Phải nhập tên khách hàng"></asp:RequiredFieldValidator>

                            <cc1:ValidatorCalloutExtender TargetControlID="R2" ID="ValidatorCalloutExtender2"
                                runat="server" Enabled="True"></cc1:ValidatorCalloutExtender>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            &#272;&#7883;a ch&#7881;
                        </td>
                        <td width="33%" colspan="7">
                            <asp:TextBox ID="txtDiaChi" runat="server" Width="250px"></asp:TextBox>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            Mã t&#432; v&#7845;n viên
                        </td>
                        <td width="21%" colspan="2">
                            <asp:TextBox AutoPostBack="True" ID="txtMaTuVanVien" runat="server" OnTextChanged="txtMaTuVanVien_TextChanged"></asp:TextBox>

                            <div id="divwidth" style="overflow: scroll; height: 150px; display: none">
                            </div>
                            <cc1:AutoCompleteExtender CompletionSetCount="12" CompletionInterval="10" MinimumPrefixLength="1"
                                ServiceMethod="GetTuVanVienInfo" TargetControlID="txtMaTuVanVien" ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx"
                                ID="AutoCompleteExtender1" runat="server" CompletionListItemCssClass="AutoExtenderList"
                                DelimiterCharacters="" Enabled="True" CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                CompletionListElementID="divwidth" CompletionListCssClass="AutoExtender"></cc1:AutoCompleteExtender>

                            <asp:RequiredFieldValidator ControlToValidate="txtMaTuVanVien" Display="None" ID="R3"
                                runat="server" ErrorMessage="Phải nhập mã tư vấn viên"></asp:RequiredFieldValidator>

                            <cc1:ValidatorCalloutExtender TargetControlID="R3" ID="ValidatorCalloutExtender3"
                                runat="server" Enabled="True"></cc1:ValidatorCalloutExtender>

                        </td>
                        <td width="9%">
                            <asp:ImageButton ID="ImageTimTuVanVien" Width="20px" CausesValidation="False" runat="server"
                                Height="20px" ImageUrl="~/image/Search.png" OnClick="ImageTimTuVanVien_Click" />

                        </td>
                        <td width="15%">
                            Tên t&#432; v&#7845;n viên
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txtTuVanVien" runat="server" Width="200px"></asp:TextBox>

                            <asp:RequiredFieldValidator ControlToValidate="txtTuVanVien" Display="None" ID="R4"
                                runat="server" ErrorMessage="Phải nhập tên tư vấn viên"></asp:RequiredFieldValidator>

                            <cc1:ValidatorCalloutExtender TargetControlID="R4" ID="ValidatorCalloutExtender4"
                                runat="server" Enabled="True"></cc1:ValidatorCalloutExtender>

                        </td>
                    </tr>
                    <tr>
                        <td>
                            <font color="#0000FF"><b>Nh&#7853;p s&#7843;n ph&#7849;m</b></font>
                        </td>
                        <td colspan="7">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;&nbsp;&nbsp; <u>Tên s&#7843;n ph&#7849;m</u>
                        </td>
                        <td width="21%" colspan="2">
                            <asp:DropDownList ID="DropTenhangNhap" runat="server" Width="125px"></asp:DropDownList>

                        </td>
                        <td width="9%">
                            <u>S&#7889; l&#432;&#7907;ng</u>
                        </td>
                        <td width="11%" colspan="3">
                            <asp:TextBox runat="server" Width="100px" ID="txtSoLuong"></asp:TextBox>

                        </td>
                        <td class="style1">
                            <asp:ImageButton ID="BtNhapToSession" runat="server" Width="20px" Height="20px" ImageUrl="~/image/Edit file.png"
                                CausesValidation="False" OnClick="BtNhapToSession_Click" />

                        </td>
                    </tr>
                    <tr>
                        <td colspan="8" align="center">
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="540px"
                                DataKeyNames="Mahang1" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
                                OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting">
                                <Columns>
<asp:TemplateField HeaderText="KM">
    <ItemTemplate>
                                            <asp:CheckBox ID="CheckKM" Checked='<%# Eval("LineType1") %>' runat="server" />
                                        
                                    </ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="MaHang1" HeaderText="Mã hàng" ReadOnly="True" />
<asp:BoundField DataField="TenHang1" HeaderText="Tên hàng" ReadOnly="True" />
<asp:BoundField DataField="SoLuong1" HeaderText="Số lượng" />
<asp:TemplateField HeaderText="Giá ">
    <ItemTemplate>
                                            <asp:Label ID="lblGia" Font-Bold="true" ForeColor="Blue" runat="server" Text='<%# Eval("Gia1","{0:###,###}") %>'></asp:Label>
                                        
                                    </ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ThanhTien1" DataFormatString="{0:###,###}" ReadOnly="True"
                                        HeaderText="Thành tiền">
<ControlStyle Font-Bold="True" ForeColor="Blue" />

<ItemStyle Font-Bold="True" ForeColor="Blue" />
</asp:BoundField>
<asp:CommandField CausesValidation="False" HeaderText="Sửa" ShowEditButton="True"
                                        ButtonType="Image" EditImageUrl="~/image/Burn Folder.png" EditText="Sửa" CancelImageUrl="~/image/Uploads Folder.png"
                                        CancelText="Thoát" UpdateText="Cập nhập" UpdateImageUrl="~/image/Documents Folder.png">
<ControlStyle Height="25px" Width="25px" />

<ItemStyle Height="25px" Width="25px" />
</asp:CommandField>
<asp:CommandField ButtonType="Image" DeleteText="Xóa" DeleteImageUrl="~/image/Symbol-Delete.png"
                                        CausesValidation="False" HeaderText="Xóa" ShowDeleteButton="True">
<ControlStyle Height="25px" Width="25px" />

<ItemStyle Height="25px" Width="25px" />
</asp:CommandField>
                                </Columns>
                            </asp:GridView>

                            <br />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                        <td colspan="2">
                            &nbsp;
                        </td>
                        <td class="style2" colspan="2">
                            Tổng tiền :
                        </td>
                        <td colspan="2">
                            <asp:Label BackColor="Transparent" Font-Bold="True" ForeColor="Blue" ID="lblTongTien"
                                runat="server"></asp:Label>

                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;
                        </td>
                        <td colspan="2">
                            &nbsp;
                        </td>
                        <td class="style2" colspan="2">
                            &nbsp;
                        </td>
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        
        
    </ContentTemplate>
    
</cc1:TabPanel>
    <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Tìm kiếm">
        <ContentTemplate>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="2">
    <asp:View ID="View1" runat="server">
        <table align="center" style="width: 50%;">
            <tr>
                <td align="center">
                    Nhập thông tin khách hàng&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtSearchKhachHang" runat="server" OnTextChanged="txtSearchKhachHang_TextChanged"
                                    AutoPostBack="True"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="txtViewKhachHang" runat="server" Height="20px"
                                    ImageUrl="~/image/Search.png" CausesValidation="False" 
                        OnClick="txtViewKhachHang_Click" >
                    </asp:ImageButton>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" Width="278px"
                                    AllowPaging="True" OnPageIndexChanging="GridView2_PageIndexChanging" OnRowCommand="GridView2_RowCommand"
                                    PageSize="5">
                        <Columns>
                            <asp:BoundField DataField="CustomerKey" HeaderText="Mã khách hàng" >
                            
                            </asp:BoundField>
                            <asp:BoundField DataField="CustomerName" HeaderText="Tên khách hàng" >
                            
                            </asp:BoundField>
                            <asp:BoundField DataField="Address" HeaderText="Địa chỉ" >
                            
                            </asp:BoundField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton5" runat="server" Height="20px" ImageUrl="~/image/Symbol-Check.png"
                                                    CausesValidation="False" CommandName="chon" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </asp:View>
    <asp:View ID="View2" runat="server">
        <table align="center" style="width: 50%;">
            <tr>
                <td align="center">
                    Nhập thông tin tư vấn viên&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtSearchTenTuVanVien" runat="server" OnTextChanged="txtSearchTenTuVanVien_TextChanged"
                                    AutoPostBack="True"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="TuVanVienView" runat="server" Height="20px"
                                    ImageUrl="~/image/Search.png" CausesValidation="False" 
                        OnClick="TuVanVienView_Click" >
                    </asp:ImageButton>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" Width="278px"
                                    AllowPaging="True" OnPageIndexChanging="GridView3_PageIndexChanging" OnRowCommand="GridView3_RowCommand"
                                    PageSize="5">
                        <Columns>
                            <asp:BoundField DataField="salesp_key" HeaderText="Mã tư vấn viên" />
                            <asp:BoundField DataField="salesp_name" HeaderText="Tên tư vấn viên" />
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton8" runat="server" Height="20px" ImageUrl="~/image/Symbol-Check.png"
                                                    CausesValidation="False" CommandName="chon" Width="20px" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </asp:View>
    <asp:View ID="view3" runat="server">
        <table align="center" style="width: 50%;">
            <tr>
                <td align="center">
                    Nhập thông tin phiếu mua hàng&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtSearchPhieuMuaHang" runat="server" AutoPostBack="True" OnTextChanged="txtSearchPhieuMuaHang_TextChanged"></asp:TextBox>
                    &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="PhieuMuaHangView" runat="server" CausesValidation="False"
                                    Height="20px" Width="20px" ImageUrl="~/image/Search.png" 
                        OnClick="PhieuMuaHangView_Click" >
                    </asp:ImageButton>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <asp:GridView ID="GridView4" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                    OnPageIndexChanging="GridView4_PageIndexChanging" OnRowCommand="GridView4_RowCommand"
                                    PageSize="5" Width="350px">
                        <Columns>
                            <asp:BoundField DataField="InvNo" HeaderText="Số chứng từ" />
                            <asp:BoundField DataField="CustomerName" HeaderText="Tên khách hàng" >
                            
                            </asp:BoundField>
                            <asp:BoundField DataField="InvDate" HeaderText="Ngày" />
                            <asp:CheckBoxField HeaderText="Chốt" DataField="Posted" >
                            
                            </asp:CheckBoxField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton9" runat="server" CausesValidation="False" CommandName="chon"
                                                    Width="20px" Height="20px" ImageUrl="~/image/Symbol-Check.png" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </asp:View>
            </asp:MultiView>
        
    </ContentTemplate>
    
</cc1:TabPanel>
</cc1:tabcontainer>
<%--</ContentTemplate>
</asp:UpdatePanel>--%>
<uc2:uscmsgbox id="uscMsgBox1" runat="server" />
